<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>


<body>


</body>
<script>
    {   //forEach（）遍历 为每个数组元素调用函数
        let checklist = [true, false, true, false]
        checklist.forEach(item => {
            item = false
        })
        console.log(checklist);
    }
    {
        let arr = [{ a: 1 }, { b: 2 }]
        arr.forEach(item => {
            item.a = 888
        })
        console.log(arr);
    }
    { //map() 遍历 使用为每个数组元素调用函数结果创建新数组。返回新数组
        let checklist = [true, false, true, false]
        let res = checklist.map(item => {
            item = false
            return false
        })
        console.log(res);
    }
    {
        let arr = [{ a: 1 }, { b: 2 }]
        arr.map(item => {
            item.a = 888
        })
        console.log(arr);
    }
    {   //every() 检查数组中的每个元素是否通过测试，返回布尔值
        let arr = [1, 2, 3, 4]
        let res = arr.every(item => {
            return item > 3
        })
        console.log(res);
    }
</script>


</html>